# @FileName  : str.py
# @Time      : 2021/7/14 0014  18:15
# @Author    : LuZhaoHui
# @Software  : PyCharm

def isListInStr(s, s_list):
    if s in s_list:
        return True
    for item in s_list:
        if item in s:
            return True
    return False

def listToStr(s_list):
    s = str(s_list)
    s = s.lstrip('[')
    s = s.rstrip(']')
    return s

def format_number(amount):
    zheng = str(amount)
    res = []
    while True:
        if len(zheng) > 3:
            str1 = zheng[-3:]
            zheng = zheng[0:len(zheng) - 3]
            res.insert(0, str1)
        else:
            res.insert(0, zheng)
            break
    result = ','.join(res)
    return result


def get_size_byte_kb(byte):
    return int((byte + 512) / 1024)


def get_pix_w(pix):
    return int((pix + 5000) / 10000)


def get_step_range_mm(step):
    return step / 1000 * 20.0


def get_range_mm_step(mm):
    return int(mm * 1000 / 20.0)


def list_find(find_list, item):
    try:
        index = find_list.index(item)
    except ValueError:
        index = -1
    return index


def trim_list(find_list):
    index = [i for i, x in enumerate(find_list) if x == '' or x == ' ']
    for i in index[::-1]:
        del find_list[i]
    return find_list


def remove_last(text):
    return text[:text[:-1].rindex('\n') - len(text)]


def str_right(ss, str_len):
    s = ss
    if len(ss) > str_len:
        s = '...' + ss[(len(ss) - str_len):]
    return s


def is_vl(model_name):
    return model_name.find('-VL-') > 0
